package com.likeycy.my.singly;

import com.likeycy.my.List;

/**
 * @ClassName: TestMySinglyLinkedList
 * @Description: 测试自己实现的链表
 * @Author: sodagreen
 * @Date: 2021/2/23 3:07
 * @Version: 1.0
 */
public class TestMySinglyLinkedList {

    public static void main(String[] args) {
        testMySinglyLinkedList();

        testMyDummyHeaderSinglyLinkedList();
    }

    public static void testMySinglyLinkedList() {
        List<String> stringMySinglyLinkedList = new MySinglyLinkedList<>();
        stringMySinglyLinkedList.add("我");
        stringMySinglyLinkedList.add("我");
        stringMySinglyLinkedList.add(null);
        stringMySinglyLinkedList.add("爱");
        stringMySinglyLinkedList.add("杨超越");
        String s = stringMySinglyLinkedList.get(4);
        System.out.println(stringMySinglyLinkedList);
        System.out.println(s);

        List<Integer> integerList = new MySinglyLinkedList<>();
        integerList.add(20);
        integerList.add(0, 10);
        integerList.add(30);
        integerList.add(integerList.size(), 40);
        integerList.remove(1);
        System.out.println(integerList);
        System.out.println(integerList.size());
    }


    public static void testMyDummyHeaderSinglyLinkedList() {
        MyDummyHeaderSinglyLinkedList<Integer> dummyHeaderSinglyLinkedList = new MyDummyHeaderSinglyLinkedList<>();
        // dummyHeaderSinglyLinkedList.remove(0);
        System.out.println("空集合indexOf:Method:result → " + dummyHeaderSinglyLinkedList.indexOf(11));
        dummyHeaderSinglyLinkedList.add(22);
        dummyHeaderSinglyLinkedList.add(0, 11);
        dummyHeaderSinglyLinkedList.add(33);
        dummyHeaderSinglyLinkedList.add(dummyHeaderSinglyLinkedList.size(), 44);
        dummyHeaderSinglyLinkedList.remove(1);
        System.out.println("有元素的集合indexOf:Method:result → " + dummyHeaderSinglyLinkedList.indexOf(11));
        System.out.println(dummyHeaderSinglyLinkedList);
    }
}
